﻿using HAF.Core;
using HAF.LogUtility;
using MediaBusiness.Dto;
using SqlSugar;
using System.Collections.Generic;

namespace MediaBusiness.Utils
{
    /// <summary>
    /// 数据访问控制器
    /// </summary>
    public class DataAssistantor: Singletonable<DataAssistantor>
    {
        /// <summary>
        /// 获取剧头数据
        /// </summary>
        /// <param name="bTime"></param>
        /// <param name="eTime"></param>
        /// <returns></returns>
        public List<MediaHeadsDto> GetMediaMetainfo(string bTime, string eTime)
        {
            BaseDal<MediaHeadsDto> baseDal = new BaseDal<MediaHeadsDto>();
            //baseDal.
            //Like语法 SqlFunc.Like(q.MediaID,"JHT%")  && q.MediaID.Contains("JHT") "2025-09-08" "2025-09-15"
            //DbMethods.Like(q.MediaID, "JHT%");
            var rtnObjs = baseDal.Query(q => q.BEnable && SqlFunc.Between(q.CreateTime, bTime, eTime)
            && q.Action == "REGIST" && !SqlFunc.Like(q.MediaID, "JHT%")
            );
            if (rtnObjs != null)
            {
                LogHelper.WriteDebugLog("共查询到{0}条剧头数据", rtnObjs.Count);
                return rtnObjs;
            }
            else
            {
                LogHelper.WriteErrorLog("未查询到数据");
                return null;
            }
        }
    }
}
